package com.xwj.dto;

import org.apache.commons.lang3.StringUtils;

import java.beans.Transient;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * Created by xuweijie on 2018/1/28.
 */
public class CreateCloudHouseInfoDto implements Serializable {
    private static final long serialVersionUID = -5335659403407089754L;
    private String name;
    private BigDecimal lon;
    private BigDecimal lat;
    private String address;
    private String id;

    public CreateCloudHouseInfoDto() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getLon() {
        return lon;
    }

    public void setLon(BigDecimal lon) {
        this.lon = lon;
    }

    public BigDecimal getLat() {
        return lat;
    }

    public void setLat(BigDecimal lat) {
        this.lat = lat;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Transient
    public void setLocation(String location) {
        if (StringUtils.isBlank(location))
            return;
        String[] str = location.split(",");
        this.lon = BigDecimal.valueOf(Double.parseDouble(str[0]));
        this.lat = BigDecimal.valueOf(Double.parseDouble(str[1]));
    }

    @Override
    public String toString() {
        return "CreateCloudHouseInfoDto{" +
                "name='" + name + '\'' +
                ", lon=" + lon +
                ", lat=" + lat +
                ", address='" + address + '\'' +
                ", id='" + id + '\'' +
                '}';
    }
}
